package demo.practice.binary_search;

public class P50 {

    public static void main(String[] args) {
        P50 p50 = new P50();
        double v = p50.myPow(2.00000, -2147483648);
        System.out.println(v);
    }

    public double myPow(double x, int n) {

        if(n==Integer.MIN_VALUE)
            return x*myPow(x,n-1);

        if (n == 0)
            return 0;


        double res = 0;
        boolean ne = n < 0; //负数
        n = Math.abs(n);
        if(n==1)
            res=x;

        if (n>1&&(n & 1) == 0) {
            double r1=myPow(x, n / 2);
            res=r1*r1;
        } else if(n>1) {
            res = myPow(x, n - 1) * x;
        }

        if (ne)
            return 1 / res;

        return res;
    }
}
